package com.rem.time.part2;

import org.junit.Test;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Set;

/**
 * 时区处理
 * <p>
 * ZoneDate  ZonedTime  ZonedDateTime
 *
 * @Author Rem
 * @Date 2020-02-15
 */

public class TestZoned {

    @Test
    public void test() {
        Set<String> availableZoneIds = ZoneId.getAvailableZoneIds();

        //所有的时区
        availableZoneIds.forEach(System.out::println);
    }

    @Test
    public void test2() {
        //America/New_York
        LocalDateTime new_york = LocalDateTime.now(ZoneId.of("America/New_York"));
        System.out.println("纽约时间：" + new_york);

        LocalDateTime now = LocalDateTime.now(ZoneId.of("Europe/Paris"));
        ZonedDateTime zonedDateTime = now.atZone(ZoneId.of("Europe/Paris"));
        System.out.println("带时区的日期：" + zonedDateTime);
    }
}
